package com.jrauto.CarAppBackend.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.jrauto.CarAppBackend.entity.dto.MediaCheckDTO;
import com.jrauto.CarAppBackend.entity.dto.TextSecurityCheckDTO;
import com.jrauto.CarAppBackend.entity.vo.SecurityCheckResult;
import com.jrauto.CarAppBackend.service.SecurityCheckService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author : huiMing
 * Date : 2025年09月18日 16:10
 * @version V1.0
 */

@RestController
@RequestMapping("/check")
public class SecurityCheckController {

    @Resource
    private SecurityCheckService securityCheckService;

    /**
     * 文本内容安全识别接口
     * @param request 文本内容请求体
     * @return 识别结果
     */
    @PostMapping("/wx/text")
    public SecurityCheckResult textCheck(@RequestBody TextSecurityCheckDTO request) throws JsonProcessingException {
        return securityCheckService.msgSecCheck(request);
    }

    /**
     * 多媒体内容安全识别接口
     * @param request 多媒体内容请求体
     * @return 异步任务结果（包含trace_id）
     */
    @PostMapping("/wx/media")
    public Map<String, Object> mediaCheckAsync(@RequestBody MediaCheckDTO request) {
        return securityCheckService.mediaCheckAsync(request);
    }
}
